home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / tupleobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  1.6 KB  |  48 lines

  1. #ifndef Py_TUPLEOBJECT_H
  2. #define Py_TUPLEOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Tuple object interface */
  8.  
  9. /*
  10. Another generally useful object type is an tuple of object pointers.
  11. This is a mutable type: the tuple items can be changed (but not their
  12. number).  Out-of-range indices or non-tuple objects are ignored.
  13.  
  14. *** WARNING *** PyTuple_SetItem does not increment the new item's reference
  15. count, but does decrement the reference count of the item it replaces,
  16. if not nil.  It does *decrement* the reference count if it is *not*
  17. inserted in the tuple.  Similarly, PyTuple_GetItem does not increment the
  18. returned item's reference count.
  19. */
  20.  
  21. typedef struct {
  22.     PyObject_VAR_HEAD
  23.     PyObject *ob_item[1];
  24. } PyTupleObject;
  25.  
  26. extern DL_IMPORT(PyTypeObject) PyTuple_Type;
  27.  
  28. #define PyTuple_Check(op) ((op)->ob_type == &PyTuple_Type)
  29.  
  30. extern DL_IMPORT(PyObject *) PyTuple_New Py_PROTO((int size));
  31. extern DL_IMPORT(int) PyTuple_Size Py_PROTO((PyObject *));
  32. extern DL_IMPORT(PyObject *) PyTuple_GetItem Py_PROTO((PyObject *, int));
  33. extern DL_IMPORT(int) PyTuple_SetItem Py_PROTO((PyObject *, int, PyObject *));
  34. extern DL_IMPORT(PyObject *) PyTuple_GetSlice Py_PROTO((PyObject *, int, int));
  35. extern DL_IMPORT(int) _PyTuple_Resize Py_PROTO((PyObject **, int, int));
  36.  
  37. /* Macro, trading safety for speed */
  38. #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
  39. #define PyTuple_GET_SIZE(op)    (((PyTupleObject *)(op))->ob_size)
  40.  
  41. /* Macro, *only* to be used to fill in brand new tuples */
  42. #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
  43.  
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif /* !Py_TUPLEOBJECT_H */
  48.